package com.caiyouxi.advertise.service.impl;

import com.caiyouxi.advertise.mapper.SlideDetailMapper;
import com.caiyouxi.advertise.model.SlideDetail;
import com.caiyouxi.advertise.service.SlideDetailService;
import com.caiyouxi.common.bean.ResData;
import com.caiyouxi.common.exception.ErrorCode;
import com.caiyouxi.common.service.BaseService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SlideDetailServiceImpl extends BaseService implements SlideDetailService {

    private Logger logger = Logger.getLogger(SlideDetailServiceImpl.class);

    @Autowired
    SlideDetailMapper mapper;
    @Override
    public ResData get_slide_list(SlideDetail bean) {
        return success(mapper.get_slide_list(bean));
    }

    @Override
    public ResData add_slide(SlideDetail bean) {
        int result = mapper.insert(bean);
        if(result == 1){
            return success(null);
        }else {
            return failed(ErrorCode.SYS_BUSSINESS_ERROR.getCode(),ErrorCode.SYS_BUSSINESS_ERROR.getMsg(),null);
        }
    }

    @Override
    public ResData update_slide(SlideDetail bean) {
        int result = mapper.update(bean);
        if(result == 1){
            return success(null);
        }else {
            return failed(ErrorCode.SYS_BUSSINESS_ERROR.getCode(),ErrorCode.SYS_BUSSINESS_ERROR.getMsg(),null);
        }
    }

    @Override
    public ResData get_slide_info(SlideDetail bean) {
        return success(mapper.get_by_id(bean.getId()));
    }
}
